<template>
  <div class="combos-item">
    <el-checkbox
      style="margin-bottom:15px;"
      :indeterminate="isIndeterminate"
      v-model="checkAll"
      @change="handleCheckAllChange"
    >{{title}}</el-checkbox>
    <!-- <div style="margin: 15px 0;"></div> -->
    <el-checkbox-group v-model="value" @change="handleCheckedCitiesChange">
      <el-checkbox v-for="item in options" :label="item" :key="item">{{item}}</el-checkbox>
    </el-checkbox-group>
  </div>
</template>
<script>

export default {
  props: {
    title: {
      type: String
    },
    options: {
      type: Array
    }
  },
  data() {
    return {
      checkAll: false,
      value: [],
      isIndeterminate: true
    };
  },
  created() {
    // this.getCombos();
  },
  mounted() {
    if (this.options && this.options.length) {
      this.value = [this.options[0]];
    }
  },
  methods: {
    handleCheckAllChange(val) {
      this.value = val ? this.options : [];
      this.isIndeterminate = false;
    },
    handleCheckedCitiesChange(value) {
      let checkedCount = value.length;
      this.checkAll = checkedCount === this.options.length;
      this.isIndeterminate =
        checkedCount > 0 && checkedCount < this.options.length;
    },
    //获取选中的权限pid
    
  }
};
</script>
<style lang="scss">
.combos-item {
  text-align: left;
  margin-left: 20px;
}
</style>